﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace inventory.forms
{
    public partial class optionUpdateFromStatement : baseOptions
    {
        public enum Options : byte { UpdateData= 0,StatementStock =2};
        public optionUpdateFromStatement()
        {
            InitializeComponent();
            optionsCb.Items.Clear();
            optionsCb.Items.Add(new common.myTypes.ComboBoxItem("Tồn của lệnh xuất kho", Options.StatementStock.ToString()));
            optionsCb.Items.Add(new common.myTypes.ComboBoxItem("Dữ liệu hiện thời", Options.UpdateData.ToString()));
            optionsCb.SelectedIndex = 0;

            deliveryLotCb.DropDownStyle = ComboBoxStyle.DropDown;
        }
        public Options myOption
        {
            get
            {
                if (optionsCb.myValue == Options.StatementStock.ToString()) return Options.StatementStock;
                return Options.UpdateData;
            }
            set
            {
                switch (value)
                {
                    case Options.UpdateData: optionsCb.myValue = Options.UpdateData.ToString(); break;
                    case Options.StatementStock: optionsCb.myValue = Options.StatementStock.ToString(); break;
                }
            }
        }

        public string myDeliveryLot
        {
            get
            {
                return deliveryLotCb.Text.Trim();
            }
        }

        public void SetDeliveryLot(string[] list)
        {
            deliveryLotCb.Items.Clear();
            foreach (string item in list)
            {
                deliveryLotCb.Items.Add(new common.myTypes.KeyValueItem(item,item));
            }
            deliveryLotCb.SelectFirstIfNull();
        }

        private void optionsCb_SelectionChangeCommitted(object sender, EventArgs e)
        {
            try
            {
                deliveryLotCb.Enabled = optionsCb.SelectedIndex == 0;
            }
            catch (Exception er)
            {
                this.ShowError(er);
            }
        }
    }
}
